import request from '../utils/request';

/**
 * 获取文章列表
 */
export function getArticleDataApi(params) {
  return request({
    url: '/v1_0/mp/articles',
    params,
  });
}
/**
 * 删除文章
 */
export function delArticleByIdApi(id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
    method: 'DELETE',
  });
}
/**
 * 发布文章
 */
export function addArticleApi(data, draft = false) {
  return request({
    url: `/v1_0/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  });
}
/**
 * 获取文章详情
 */
export function getArticleDetailsApi(id) {
  return request({
    url: `/v1_0/mp/articles/${id}`,
  });
}
/**
 * 编辑文章
 */
export function editArticleApi(data, id, draft = false) {
  console.log('------------', data, id, draft);
  return request({
    url: `/v1_0/mp/articles/${id}?draft=${draft}`,
    method: 'put',
    data,
  });
}
